const path = require("path");
const express = require("express");
const cors = require("cors");
const app = express();
const port = 3333;
const fs = require("fs-extra");

app.use(cors());
app.use(express.json({ limit: "50mb" }));
app.use(express.urlencoded({ limit: "50mb" }));

app.use("/createMock", (req, res) => {
  const url = path.resolve(__dirname, `..${req.path}.json`);
  fs.ensureFileSync(url);
  fs.writeFileSync(url, JSON.stringify(req.body));
  res.send({
    msg: "ok",
  });
});

app.listen(port, (e) => {
  console.log("http://localhost:3333");
});
